package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Advertisement;
import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.mapper.AdvertisementMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IAdvertisementService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdvertisementServiceImpl implements IAdvertisementService {

    @Autowired
    private AdvertisementMapper advertisementMapper;


    @Override
    public void deleteByPrimaryKey(Long id) {
        advertisementMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(Advertisement advertisement) {
         advertisementMapper.insert(advertisement);
    }

    @Override
    public Advertisement selectByPrimaryKey(Long id) {
        return advertisementMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Advertisement> selectAll() {
        return advertisementMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Advertisement advertisement) {
        advertisementMapper.updateByPrimaryKey(advertisement);
    }

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<Advertisement> list = advertisementMapper.selectForList(qo);
        return new PageInfo(list);
    }
}
